package cn.guat.smartpark.service.impl;

import cn.guat.smartpark.entity.FireDevices;
import cn.guat.smartpark.mapper.FireDevicesMapper;
import cn.guat.smartpark.service.FireDevicesService;
import cn.guat.smartpark.utils.Fastjson2CoordinateParser;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class FireDevicesServiceImpl implements FireDevicesService {

    //依赖注入
    @Autowired
    private FireDevicesMapper fireDevicesMapper;

    @Override
    public FireDevices getDevicesById(String deviceId) {
        FireDevices fd = fireDevicesMapper.getDevicesById(deviceId);
        if(fd != null){//判断空
            if(fd.getCoordinateString() != null){//判断是否有坐标
                //调用工具类把字符串转map集合
                fd.setCoordinateData(Fastjson2CoordinateParser.parseCoordinate(fd.getCoordinateString()));
                fd.setCoordinateString(null);
                return fd;
            }
            return fd;
        }
        return null;
    }
}
